<template>
<div>{{"姓名："+name+"性别："+sex+"年龄："+age}}</div>
<div>{{infor}}</div>
<button>重新设置</button>
<div>总件数：{{goods[0].num+goods[1].num+goods[2].num+goods[3].num+goods[4].num+goods[5].num}}<small>件</small></div>
<div>总价：<small>￥</small>{{goods[0].price+goods[1].price+goods[2].price+goods[3].price+goods[4].price+goods[5].price}}</div>
<div>方法二获取总件数：{{sumnums}}<small>件</small></div>
<div>方法二获取总价：<small>￥</small>{{}}</div>
</template>
<script>
const date = {
  name:"admin",
  sex:"女",
  age:22,
  goods:[
    {num:1,price:4298.00},
    {num:2,price:1200},
    {num:4,price:25},
    {num:6,price:1.2},
    {num:13,price:2.3},
    {num:21,price:1.9},
  ]
}
export default {
  name: "App1",
  data(){
    return date;
  },
  computed:{
    // 完整写法：
    // infor:{
    //   get(){
    //     return "姓名："+this.name+"性别："+this.sex+"年龄："+this.age;
    //   }
    // },
    // 简写方式：
    infor(){
      return "姓名："+this.name+"性别："+this.sex+"年龄："+this.age;
    },
    sumnums(){
      return this.goods.reduce((a,b)=>a+b.num,0);
    }
  },

}
</script>

<style scoped>

</style>